package morncloud.com.notes.ui;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.GridView;

import morncloud.com.notes.MainActivity;
import morncloud.com.notes.R;
import morncloud.com.notes.database.DAO;


/**
 * Created by majoy on 2015/1/7.
 */
public class NotesWithGridFragment extends AbsListViewFragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.notes_grid_fragment, container, false);
        GridView grid = (GridView) view.findViewById(R.id.notes_grid);
        bindCursor(grid);
        return view;
    }
    @Override
    public void bindCursor(AbsListView absListView) {
        final NotesGridCursorAdapter adapter = new NotesGridCursorAdapter(getActivity(), DAO.getInstance(getActivity()).getAllNotes());
        absListView.setAdapter(adapter);
        ((MainActivity) getActivity()).setmDataChangeCallbacks(adapter);
        bindDataChangeCallbacks(adapter);
        bindMutilListener(adapter,absListView);
        bindItemClickListener(absListView);
    }
}
